#!/usr/bin/env python
# -*- coding: utf-8 -*-

import rospy
import dynamic_reconfigure.client
from std_msgs.msg import Int8

class Client:
    def __init__(self):
        self.client_sub = rospy.Subscriber("/change_inflation_flag", Int8 , self.callback_change_inflation)
        self.change_inflation_flag = 0

    def callback_change_inflation(self, msg):
        self.change_inflation_flag = msg.data
    
    def get_change_inflation_flag(self):
        return self.change_inflation_flag

    def reset_change_inflation_flag(self):
        self.change_inflation_flag = 0

if __name__ == '__main__':
    rospy.init_node("dynamic_reconfigure_client")
    drClient = Client.init()
    local_client = dynamic_reconfigure.client.Client("/move_base/local_costmap/inflation_layer/")
    global_client = dynamic_reconfigure.client.Client("/move_base/local_costmap/inflation_layer/")
    while not rospy.is_shutdown():
        change_inflation_flag = drClient.get_change_inflation_flag()
        if change_inflation_flag == 1:
            local_client.update_configuration({"inflation_radius": 0.1})
            drClient.reset_change_inflation_flag()

    rospy.spin()